package com.htjc.integral.activity.util;

import com.alibaba.fastjson.JSONObject;
import com.htjc.integral.activity.util.enums.ActivityReturn;

/**
 * 自定义返回结果
 * @author zw
 */
public class ResultModel {
    /**
     * 返回码
     */
    private String rcode;

    /**
     * 返回结果描述
     */
    private String message;

    /**
     * 返回内容
     */
    private Object content;

    public String getRcode() {
        return rcode;
    }

    public String getMessage() {
        return message;
    }

    public Object getContent() {
        return content;
    }

    public ResultModel(String rcode, String message) {
        this.rcode = rcode;
        this.message = message;
        this.content = "";
    }

    public ResultModel(String rcode, String message, Object content) {
        this.rcode = rcode;
        this.message = message;
        this.content = content;
    }


    //积分数据处理中心
    public ResultModel(ActivityReturn status) {
        this.rcode = String.valueOf(status.getCode());
        this.message = status.getMsg();
        this.content = "";
    }

    //积分数据处理中心
    public ResultModel(ActivityReturn status, Object content) {
        this.rcode = String.valueOf(status.getCode());
        this.message = status.getMsg();
        this.content = content;
    }


    /**
     * 
     *
     * @param content
     * @return
     */
    public static ResultModel ActivityReturnSucceed(Object content) {
        return new ResultModel(ActivityReturn.ACTIVITY_SUCCESS, content);
    }
    
    /**
     * 
     * @return
     */
    public static ResultModel ActivityReturnSucceed() {
        return new ResultModel(ActivityReturn.ACTIVITY_SUCCESS);
    }

    /**
     * 
     * @return
     */
    public static ResultModel ActivityReturnSucceed(ActivityReturn ActivityReturn) {
        return new ResultModel(ActivityReturn);
    }
    /**
     * 
     *
     * @param ActivityReturn
     * @return
     */
    public static ResultModel ActivityReturnError(ActivityReturn ActivityReturn) {
        return new ResultModel(ActivityReturn);
    }
    /**
     * 
     *
     * @param ActivityReturn
     * @return
     */
    public static ResultModel ActivityReturnError(Object obj) {
        return new ResultModel(ActivityReturn.ACTIVITY_ERROR, obj);
    }
    
    /**
     * 返回成功JSON
     * @param content
     * @return
     */
    public static JSONObject ReturnSucceedJson(Object content) {
    	return (JSONObject) JSONObject.toJSON(new ResultModel(ActivityReturn.ACTIVITY_SUCCESS, content));
    }
    
    /**
     * 返回失败JSON
     * @param content
     * @return
     */
    public static JSONObject ReturnErrorJson(Object content) {
        return (JSONObject) JSONObject.toJSON(new ResultModel(ActivityReturn.ACTIVITY_ERROR, content));
    }
}
